package com.jwt.controller;

import com.jwt.model.UserModel;
import com.jwt.service.LoginService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("user")
public class LoginController {

    @Value("${login.username}")
    private String username;

    @Value("${login.password}")
    private String password;

    @Resource
    private LoginService loginService;

    @PostMapping(value = "login")
    public String login(@RequestBody @Validated UserModel userModel) {
        return loginService.login(userModel);
    }

    @GetMapping(value = "select")
    public String select() {
        return "成功" + username + ":" + password;
    }
}
